//
//  oldMyBalanceViewController.m
//  laonianbangSupport
//
//  Created by 勇拓 李 on 18/3/9.
//  Copyright © 2018年 zaiyou. All rights reserved.
//

#import "oldMyBalanceViewController.h"
#import "oldBalance.h"
#import "oldRechargeViewController.h"

@interface oldMyBalanceViewController ()
@property (weak, nonatomic) IBOutlet UILabel *label_balance;
@property (weak, nonatomic) IBOutlet UIView *view_recharge;

@end

@implementation oldMyBalanceViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initView];
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self initData];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - initView
- (void)initView
{
    self.navigationItem.title = @"我的余额";
    
    if(![BALANCE_SINGLETON getBanlance])
    {
        _label_balance.text = @"0.00";
    }
    else
    {
        _label_balance.text = [BALANCE_SINGLETON getBanlance];
    }
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(gotoRecharge:)];
    [_view_recharge addGestureRecognizer:tap];
}

#pragma mark - initData
- (void)initData
{
    WeakSelf
    
    [BALANCE_SINGLETON requestBalanceSuccess:^(id data) {
        weakSelf.label_balance.text = data;
    } error:^(NSString *error) {
        [oldHub warningUser:error];
    }];
}

#pragma mark - recharge
- (void)gotoRecharge:(id)sender
{
    oldRechargeViewController *vc = [oldRechargeViewController new];
    [self.navigationController pushViewController:vc animated:YES];
}

@end
